import React from 'react'
import classNames from 'classnames';
import {Spin, Card} from 'antd';

import styles from './index.less';

export default class ProfileCard extends React.PureComponent {
  render() {
    const {loading, children, cover, className, layout = 'horizontal', size, title, column = 1, ...restProps} = this.props;
    const clsString = classNames(styles.profileIntro, styles[layout], className, {
      [styles.small]: size === 'small',
      [styles.large]: size === 'large',
    });

    return (
      <Spin spinning={loading}>
        <Card
          bordered={false}
          cover={!loading && cover}
          className={clsString}
          {...restProps}
        >
          {title ? <h1 className={styles.title}>{title}</h1> : null}
          {React.Children.map(children, child => React.cloneElement(child, {column}))}
        </Card>
      </Spin>
    );
  }
}
